import { defHttp } from '/@/utils/http/axios';
import { GetUserInfoModel, GetCaptchaModel } from './model/userModel';

enum Api {
  GetCaptcha = '/captcha',
  VerifyCaptcha = '/captcha/verify',
  ImgCaptcha = '/captcha/img',
  Login = '/auth/oauth/token',
  Logout = '/auth/oauth/logout',
  GetPermCode = '/auth/getPermCode',
  GetUserInfo = '/system/user/info',
}

/**
 * @description: getUserInfo
 */
export function getUserInfo() {
  return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, { errorMessageMode: 'none' });
}

export function getPermCode() {
  return defHttp.get<string[]>({ url: Api.GetPermCode });
}

export function doLogout() {
  return defHttp.post({ url: Api.Logout });
}

export function getCaptcha(params) {
  return defHttp.post<GetCaptchaModel>({ url: Api.GetCaptcha, params });
}

export function verifyCaptcha(params) {
  return defHttp.get<GetCaptchaModel>({ url: Api.VerifyCaptcha, params });
}

export function getImgCaptcha() {
  return defHttp.get<GetCaptchaModel>({ url: Api.ImgCaptcha });
}
